//------------------------------------------------------------------------------
// Copyright (c) 2008 www.dnaide.com
// Licensed under the MIT (MIT-LICENSE.txt)
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;

using DNAide.Core;

namespace DNAide.IO
{
	/// <summary>
	/// Path based helper methods
	/// </summary>
	public static partial class PathAide
	{
		/// <summary>
		/// </summary>
		/// <param name="ch"></param>
		/// <returns>Boolean</returns>
		internal static Boolean IsDirectorySeparatorChar(Char ch)
		{
			return (ch == '\\' || ch == '/');
		}

		/// <summary>
		/// </summary>
		/// <param name="pathToCheck"></param>
		/// <returns>Boolean</returns>
		internal static Boolean IsAbsolutePhysicalPath(String pathToCheck)
		{
			if (pathToCheck == null)
			{
				throw new ArgumentNullException("pathToCheck");
			}

			if (pathToCheck.Length < 3)
			{
				return false;
			}	

			// e.g c:\foo
			if (pathToCheck[1] == ':' && IsDirectorySeparatorChar(pathToCheck[2]))
				return true;

			// e.g \\server\share\foo or //server/share/foo
			return IsSharePath(pathToCheck);
		}

		/// <summary>
		/// </summary>
		/// <param name="pathToCheck"></param>
		/// <returns>Boolean</returns>
		internal static Boolean IsSharePath(String pathToCheck)
		{
			if (pathToCheck == null)
			{
				throw new ArgumentNullException("pathToCheck");
			}

			// e.g \\server\share\foo or //server/share/foo
			if (pathToCheck.Length > 2 && IsDirectorySeparatorChar(pathToCheck[0]) && IsDirectorySeparatorChar(pathToCheck[1]))
				return true;
			return false;

		}
	}
}
